#!/usr/bin/env python3
"""
配置文件
"""

import os

# DeepSeek API配置
# DEEPSEEK_API_KEY = "sk-vecbuswjvujawumjjjfeecmpuqakkhsyresyjdrlrboiouwq"
DEEPSEEK_API_KEY ="sk-d8b48b0fcd5e4ee7823d7ce71db41fde"
DEEPSEEK_API_URL = "https://api.deepseek.com/v1/chat/completions"
DEEPSEEK_MODEL = "deepseek-chat"

# 数据库配置
DATABASE_CONFIG = {
    'host': 'localhost',
    'port': 3306,
    'user': 'root',
    'password': 'mario',
    'database': 'ai_ssq',
    'charset': 'utf8mb4'
}

# 应用配置
APP_CONFIG = {
    'SECRET_KEY': 'your-secret-key-here',
    'JWT_SECRET_KEY': 'jwt-secret-key',
    'JWT_ACCESS_TOKEN_EXPIRES': False,
    'JWT_TOKEN_LOCATION': ['headers'],
    'JWT_HEADER_NAME': 'Authorization',
    'JWT_HEADER_TYPE': 'Bearer'
}

# CORS配置
CORS_CONFIG = {
    'origins': ['http://localhost:8080', 'http://127.0.0.1:8080'],
    'methods': ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
    'allow_headers': ['Content-Type', 'Authorization']
}

# 杀号规则配置
KILL_RULES_CONFIG = {
    'red_ball': {
        'long_term_threshold': 20,  # 长期未出阈值
        'high_freq_threshold': 13,  # 高频号码阈值
        'recent_overheat_threshold': 4,  # 近期过热阈值
        'zone_overheat_threshold': 20,  # 区间过热阈值
        'zone_hot_number_threshold': 4  # 区间热号阈值
    },
    'blue_ball': {
        'recent_freq_threshold': 2,  # 近期频率阈值
        'consecutive_odd_threshold': 2  # 连续奇数阈值
    }
}

# 选号规则配置
SELECT_RULES_CONFIG = {
    'red_ball': {
        'min_available_numbers': 6,  # 最少可用号码数
        'max_same_tail': 1  # 最多相同尾号数
    },
    'blue_ball': {
        'fallback_number': 1  # 降级号码
    }
}

# Flask应用配置
class Config:
    """基础配置类"""
    SECRET_KEY = APP_CONFIG['SECRET_KEY']
    JWT_SECRET_KEY = APP_CONFIG['JWT_SECRET_KEY']
    JWT_ACCESS_TOKEN_EXPIRES = APP_CONFIG['JWT_ACCESS_TOKEN_EXPIRES']
    JWT_TOKEN_LOCATION = APP_CONFIG['JWT_TOKEN_LOCATION']
    JWT_HEADER_NAME = APP_CONFIG['JWT_HEADER_NAME']
    JWT_HEADER_TYPE = APP_CONFIG['JWT_HEADER_TYPE']
    
    def get_database_uri(self):
        """获取数据库URI"""
        db_config = DATABASE_CONFIG
        return f"mysql+pymysql://{db_config['user']}:{db_config['password']}@{db_config['host']}:{db_config['port']}/{db_config['database']}?charset={db_config['charset']}"

class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True

class ProductionConfig(Config):
    """生产环境配置"""
    DEBUG = False

# 配置字典
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
} 